use chrono::{DateTime, Utc};
use serde::{Deserialize, Serialize};
use utoipa::ToSchema;

use super::NodeConf;

#[derive(Debug, Clone, Serialize, Deserialize, ToSchema, Default)]
#[serde(default, rename_all = "camelCase")]
pub struct StationInfo {
    #[serde(flatten)]
    pub config: NodeConf,
    pub folder_path: Option<String>,
    pub is_modified: bool,
    #[serde(with = "chrono::serde::ts_seconds_option")]
    pub seismic_start_time: Option<DateTime<Utc>>,
    pub is_online: bool,
    #[serde(with = "chrono::serde::ts_seconds_option")]
    pub last_heartbeat_time: Option<DateTime<Utc>>,
    pub can_collect: bool,
    pub id: i32,
}

#[allow(dead_code)]
impl StationInfo {
    pub fn boardid(&self) -> i32 {
        self.config.boardid
    }

    pub fn smprate(&self) -> i32 {
        self.config.smprate
    }

    pub fn channels(&self) -> i32 {
        self.config.channels
    }
}
